import json

from django.shortcuts import render

from goodsApp.service.collectionService import CollectionService

colService=CollectionService()
def collectionPage(request):
    user = request.session['user']
    if user==None:
        return render(request,"login.html")
    user = json.loads(user)
    cur = request.GET.get('page',1)
    size = request.GET.get('size',10)
    result = colService.getGoods(user_id=user['id'],cur=cur,size=size)
    total_page = colService.getTotalGoods(user_id=user['id'])
    return render(request=request,
                  template_name="collection.html",
                  context={'goods_list':result,'total_page':total_page})